package zhouzhouyongche.action;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.alibaba.fastjson.JSON;

import zhouzhouyongche.model.Passenger;
import zhouzhouyongche.service.PassengerService;

@Controller
@Action(value = "passenger")
public class PassengerAction extends BaseAction {

	private static final long serialVersionUID = 1L;

	@Autowired
	private PassengerService passengerService;
	
	private int passengerId;
	private int userId;
	private String passengerName;
	private String passengerIdNumber;
	
	public void savePassenger() {
		int b = passengerService.savePassenger(userId, passengerName, passengerIdNumber);
		writeJson(b);
	}
	
	public void getPassenger() {
		List<Passenger> passengers = passengerService.getPassenger(userId);
		writeJson(passengers.size(), passengers);
	}
	
	public void deletePassenger() {
		int b = passengerService.deletePassenger(passengerId);
		writeJson(b);
	}
	
	public int getPassengerId() {
		return passengerId;
	}

	public void setPassengerId(int passengerId) {
		this.passengerId = passengerId;
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public String getPassengerName() {
		return passengerName;
	}

	public void setPassengerName(String passengerName) {
		this.passengerName = passengerName;
	}

	public String getPassengerIdNumber() {
		return passengerIdNumber;
	}

	public void setPassengerIdNumber(String passengerIdNumber) {
		this.passengerIdNumber = passengerIdNumber;
	}
}
